unit Imp_PlaInfCep;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Rel, RDprint, ExtCtrls, StdCtrls, CheckLst, ComCtrls,
  Buttons, Mask, ToolEdit, CurrEdit, TFlatButtonUnit;

type
  TFrmImp_PlaInfCep = class(TFrmPad_Rel)
    Label1: TLabel;
    ed_qtde: TCurrencyEdit;
    procedure ed_qtdeExit(Sender: TObject);
    procedure bimprimirClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmImp_PlaInfCep: TFrmImp_PlaInfCep;

implementation

uses Imp_PlaInfCepQ,dm,dbtables,clsCausas_Parada;

{$R *.DFM}

procedure TFrmImp_PlaInfCep.ed_qtdeExit(Sender: TObject);
begin
  inherited;
 if ed_qtde.value<=0 then ed_qtde.value:= 1;
end;

procedure TFrmImp_PlaInfCep.bimprimirClick(Sender: TObject);
var form_imp: TFrmImp_PlaInfCepQ;
    tq      : TQuery;
    i       : integer;
    causa   : TCausas_Parada;
    xdesc   : string;
begin
  inherited;
 form_imp:= TFrmImp_PlaInfCepQ.Create(self);
 try
  form_imp.l_causa1.caption := '';
  form_imp.l_causa2.caption := '';
  form_imp.l_causa3.caption := '';
  form_imp.l_causa4.caption := '';
  form_imp.l_causa5.caption := '';
  form_imp.l_causa6.caption := '';
  form_imp.l_causa7.caption := '';
  form_imp.l_causa8.caption := '';
  form_imp.l_causa9.caption := '';
  form_imp.l_causa10.caption:= '';
  form_imp.l_causa11.caption:= '';
  form_imp.l_causa12.caption:= '';
  xplan_qtde:= trunc(ed_qtde.value*26);
  if ed_qtde.value>1 then inc(xplan_qtde);
  i         := 1;
  tq        := TQuery.Create(self);
  causa     := TCausas_Parada.Create;
  causa.Recuperar_Todas(tq);
  while not tq.eof do begin
   xdesc:= tq.fieldbyname('Cod_Causa').asstring+'-'+tq.fieldbyname('Descricao_Causa').asstring;
   if i=1  then form_imp.l_causa1.caption := xdesc;
   if i=2  then form_imp.l_causa2.caption := xdesc;
   if i=3  then form_imp.l_causa3.caption := xdesc;
   if i=4  then form_imp.l_causa4.caption := xdesc;
   if i=5  then form_imp.l_causa5.caption := xdesc;
   if i=6  then form_imp.l_causa6.caption := xdesc;
   if i=7  then form_imp.l_causa7.caption := xdesc;
   if i=8  then form_imp.l_causa8.caption := xdesc;
   if i=9  then form_imp.l_causa9.caption := xdesc;
   if i=10 then form_imp.l_causa10.caption:= xdesc;
   if i=11 then form_imp.l_causa11.caption:= xdesc;
   if i=12 then form_imp.l_causa12.caption:= xdesc;
   inc(i);
   tq.next;
  end;
  tq.close;
  tq.free;
  form_imp.QuickRep1.Preview;
 finally
  form_imp.free;
 end;
end;

end.
